package com.pengbei.enshrine.ui.login;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;


import com.pengbei.enshrine.R;
import com.pengbei.enshrine.network.bean.WelecomBannerModel;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;

public class WelecomBannerAdapter extends BannerAdapter<WelecomBannerModel, WelecomBannerAdapter.BannerViewHolder> {

    private Context context;
    public WelecomBannerAdapter(Context context, List<WelecomBannerModel> mDatas) {
        //设置数据，也可以调用banner提供的方法,或者自己在adapter中实现
        super(mDatas);
        this.context = context;
    }

    @Override
    public BannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_welecom, parent, false);
        return new BannerViewHolder(view);
    }

    @Override
    public void onBindView(BannerViewHolder holder, WelecomBannerModel data, int position, int size) {

        switch (data.getType()){
            case "0":
                holder.img_welecom_bg.setImageResource(R.drawable.splash_screen);
                break;
            case "1":
                holder.img_welecom_bg.setImageResource(R.drawable.splash_screen);
                break;
            case "2":
                holder.img_welecom_bg.setImageResource(R.drawable.splash_screen);
                break;
        }

        holder.tv_welecom_title.setText(data.getTitle());
        holder.tv_welecom_subtitle.setText(data.getSubtitle());
    }

    class BannerViewHolder extends RecyclerView.ViewHolder {
        ImageView img_welecom_bg;
        TextView tv_welecom_title;
        TextView tv_welecom_subtitle;

        public BannerViewHolder(@NonNull View view) {
            super(view);
            img_welecom_bg = view.findViewById(R.id.img_welecom_bg);
            tv_welecom_title = view.findViewById(R.id.tv_welecom_title);
            tv_welecom_subtitle = view.findViewById(R.id.tv_welecom_subtitle);

        }
    }

}
